<?php
/*
 * Admin Lookup Page (FST)
 * Directly look up what's stored in the cache.
 * Abe Yang <abeyang@cal.berkeley.edu> (c) 2008
 * http://code.google.com/p/flickrsetsbytag/
 *
/* ---------------------------------------------------------------------------------- */

require('../fst.class.php');

	$fst = new FST();
	$title = 'Admin Lookup Page (FST)';
	$subtitle = 'Directly look up what\'s stored in the cache.';

	$album = $_GET['album'];
	$update = $_POST['update'];
	$text = $_POST['text'];

	if ($album) {
		if ($album == 'allalbumslist') {
			$updatevalue = 'cache_fst_' . $album;
			$fst->getAllAlbumsList();
			$data = $fst->allalbums;
		}
		else {
			$udpatevalue = 'cache_fst_album' . $album;
			$data = $fst->getAlbum($album);
		}
		$updatevalue .= $album;
	}
	else if ($update) {
		// ...
	}
	else $disabled = true;
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title><?php echo $title; ?></title>
	
	<link rel="stylesheet" href="fst.css" type="text/css" media="screen" charset="utf-8" />


</head>

<body>

<div id="container">
	<h1><?php echo $title; ?></h1>
	<h2><?php echo $subtitle; ?></h2>

	<form action="#" method="get" accept-charset="utf-8">
		<?php echo $fst->showAllAlbumsListWidget() ?>
		<input type="submit" value="Load &darr; &nbsp;" />
		or <a href="?album=allalbumslist">Load all-albums list</a>
	</form>
	
	<?php if (!$disabled) { ?>
	<h2>Loaded <?php echo $updatevalue ?></h2>
	<form action="admin_direct.php" method="post" accept-charset="utf-8">
		<textarea name="text" rows="40" cols="80"><?php print_r($data) ?></textarea>
		<p>
			<input type="hidden" name="album" value="<?php echo $album ?>" id="update" <?php echo $disabled ?>/>
			<!-- <input type="submit" value="Update &rarr; &nbsp;" disabled="disabled" /> -->
		</p>
	</form>
	<?php } // end if ?>

</div> <!-- end #container -->

</body>
</html>
